/********************************************************************************
 * @Author: Zhenzhou Liu
 * @Date: 2024-11-19
 * @Description: Cg分治练习之逆序对
 *******************************************************************************/
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

int maxReversePairs(vector<int>& nums, int low, int high) {
    if (low == high) {
        return 0;
    } else {
        int midden = low + ((high - low) >> 1);
        int leftNums = maxReversePairs(nums, low, midden);
        int rightNums = maxReversePairs(nums, midden + 1, high);

        int i = 0, j = midden + 1 - low, k = low, limit1 = midden - low, limit2 = high - low;
        vector<int> temp(nums.begin() + low, nums.begin() + high + 1);
        int sum = 0;
        while (i <= limit1 && j <= limit2) {
            if (temp[i] <= temp[j]) {
                nums[k++] = temp[i++];
            } else {
                sum += limit1 - i + 1;
                nums[k++] = temp[j++];
            }
        }
        while (i <= limit1) {
            nums[k++] = temp[i++];
        }

        while (j <= limit2) {
            nums[k++] = temp[j++];
        }
        return sum + leftNums + rightNums;
    }
}

int main() {
    string input;
    getline(cin, input);
    int temp;
    stringstream ss(input);
    vector<int> nums;
    while (ss >> temp) {
        if (ss.peek() == ',') {
            ss.ignore();
        }
        nums.push_back(temp);
    }

    cout << maxReversePairs(nums, 0, nums.size() - 1);
    return 0;
}